import request from './request.js'
const accountInfo = uni.getAccountInfoSync()
const appId = accountInfo.miniProgram.appId;
import config from '@/config.js'

function getActivityList(venueId) {
	return request({
		url: `/logex/activity/activeList?venueId=${venueId}`,
		method: 'get'
	})
}
function getActivityDetail(id) {
	return request({
		url: `/logex/activity/${id}`,
		method: 'get',
		params: id
	})
}


function getActivityHotelList(params) {
	return request({
		url: `/logex/activityHotel/list`,
		method: 'get',
		params: params
	})
}
function getHotelById(id) {
	return request({
		url: `/logex/hotel/${id}`,
		method: 'get',
		params: id
	})
}

function getHotelRooms(id) {
	return request({
		url: `/logex/activityRoom/list?hotelId=${id}`,
		method: 'get',
		params: id
	})
}
function getbilllist(userId,venueId) {
	return request({
		url: `/logex/order/list?createById=${userId}&venueId=${venueId}`,
		method: 'get',
		params: userId
	})
}
function newbilllist(userId,venueId) {
	return request({
		url: `/logex/norder/list?createById=${userId}&venueId=${venueId}`,
		method: 'get',
		params: userId
	})
}
function getCanInvoiceBills(params) {
	return request({
		url: `/logex/norder/list?activeId=${params.activeId}&createById=${params.userId}&invoiced=1&venueId=${params.venueId}`,
		method: 'get'
	})
}
function getbilldetailbyId(orderId) {
	return request({
		// url: `/logex/order/${orderId}`,
		url: `/logex/norder/${orderId}`,
		method: 'get',
		params: orderId
	})
}
function getFoodBilldetailbyId(orderId) {
	return request({
		url: `/logex/orderFood/getFoodOrderInfoByOrder?orderId=${orderId}`,
		method: 'get'
	})
}
function getRoomBilldetailbyId(orderId) {
	return request({
		url: `/logex/orderRoom/getRoomOrderInfoByOrderId?orderId=${orderId}`,
		method: 'get'
	})
}
function getCarBilldetailbyId(orderId) {
	return request({
		url: `/logex/norder/getOrderByOrderId?orderId=${orderId}`,
		method: 'get'
	})
}
function getInvoiceByActiveId(activeId,userId,venueId) {
	return request({
		url: `/logex/invoice/list?activeId=${activeId}&createById=${userId}&venueId=${venueId}`,
		method: 'get'
	})
}
function getInvoiceByUserId(userId,venueId) {
	return request({
		url: `/logex/invoice/list?createById=${userId}&venueId=${venueId}`,
		method: 'get'
	})
}
function getInvoiceDetailBills(invoiceId) {
	return request({
		url: `/logex/norder/list?invoiceId=${invoiceId}`,
		method: 'get'
	})
}
function getInvoiceDetail(invoiceId) {
	return request({
		url: `/logex/invoice/${invoiceId}`,
		method: 'get'
	})
}
function submitOrder(data) {
	return request({
		url: `/logex/order/submitOrder`,
		method: 'post',
		params: data
	})
}
// 退款
function cancelOrder(orderId) {
	return request({
		// url: `/logex/norder/unSubscribeOrderBack/${orderId}`,
		url: `/logex/norder/applyOrderBack/${orderId}`,
		method: 'post',
		params: orderId
	})
}
// 取消
function cancelOrder2(orderId) {
	return request({
		url: `/logex/norder/cancelOrderBack//${orderId}`,
		method: 'post',
		params: orderId
	})
}

function payForOrder(orderId) {
	const nowOpenId = uni.getStorageSync('nowOpenId');
	return request({
		// url: `/logex/order/payForOrder?orderId=${orderId}&openId=${nowOpenId}`,
		url: `/logex/norder/payForOrder?orderId=${orderId}&openId=${nowOpenId}`,
		method: 'post',
		params: orderId
	})
}
function submitInvoice(form) {
	return request({
		url: `/logex/invoice`,
		method: 'post',
		params: form
	})
}
function editInvoice(form) {
	return request({
		url: `/logex/invoice`,
		method: 'put',
		params: form
	})
}
function addAddress(form) {
	return request({
		url: `/logex/invoiceInfo`,
		method: 'post',
		params: form
	})
}
function checkResidueRoom(form) {
	return request({
		url: `/logex/orderRoom/checkResidueRoom`,
		method: 'post',
		params: form
	})
}
function delAddress(ids) {
	return request({
		url: `/logex/invoiceInfo/${ids}`,
		method: 'delete'
	})
}
function regionsList() {
	return request({
		url: `/systemj/region/regionsList`,
		method: 'get'
	})
}
function addressList() {
	const currUser = uni.getStorageSync('currUser');
	return request({
		url: `/logex/invoiceInfo/list?createById=${currUser.userId}`,
		method: 'get'
	})
}
function getActivityRestaurantList(params) {
	return request({
		url: `/logex/activityRestaurant/list`,
		method: 'get',
		params: params
	})
}
function getActivityCarList(params) {
	return request({
		url: `/logex/activityVehicle/wxList`,
		method: 'get',
		params: params
	})
}
function getMenuById(id) {
	return request({
		url: `/logex/activityFood/list?larId=${id}`,
		method: 'get'
	})
}
function submitOrderFood(form) {
	return request({
		url: `/logex/norder/submitOrderFood`,
		method: 'post',
		params: form
	})
}
function submitOrderCar(form) {
	return request({
		url: `/logex/norder/submitOrderCar`,
		method: 'post',
		params: form
	})
}
function newsSubmitOrderHotel(form) {
	return request({
		url: `/logex/norder/submitOrderRoom`,
		method: 'post',
		params: form
	})
}
export {getActivityList,getActivityHotelList,getActivityDetail,getHotelById,getHotelRooms,submitOrder,getbilllist,getbilldetailbyId,
payForOrder,cancelOrder,getCanInvoiceBills,submitInvoice,getInvoiceByActiveId,getInvoiceDetailBills,
getInvoiceDetail,getInvoiceByUserId,editInvoice,addAddress,regionsList,addressList,delAddress,
checkResidueRoom,getActivityRestaurantList,getMenuById,
submitOrderFood,getActivityCarList,submitOrderCar,newsSubmitOrderHotel,newbilllist,
getFoodBilldetailbyId,getRoomBilldetailbyId,getCarBilldetailbyId,
cancelOrder2
}